<div class="call-me-form">
	<div class="contacts-info__form">
		<h3 class="popup-title">Оставить заявку на обратный звонок</h3>
		<?php
		$form = $this->beginWidget('CActiveForm', array(
			'id' => 'request-form-02',
			'action' => '/main/ajax/request?pageTitle='.  urlencode( $pageTitle ) . '&pageUrl=' . urlencode( $pageUrl ),
			'enableClientValidation' => true,
			'clientOptions' => array(
				'validateOnSubmit' => true,
			),
		));
		?>
		<div style="display: none">			
			<?php echo $form->error($model, 'userPhone'); ?>
		</div>
		<fieldset>
			<div class="type-text">
				<?php echo $form->textField($model, 'userPhone', array('placeholder' => 'Ваш телефон', 'class' => 'masked-phone', 'id'=>'test-02')); ?>
			</div>
		</fieldset>
		<fieldset>
                    <ul id="curer">
				<li>
					<div class="radio">
						<input id="status" type="radio" checked="checked" name="choice" value="status" />
						<label for="status">
							<span class="radio__box">
								<span class="radio__box__inner">&nbsp;</span>
							</span>    
							<span class="radio__text">Я хочу узнать статус ремонта</span>
						</label>
					</div>
				</li>
				<li>
					<div class="radio">
						<input id="client" type="radio" name="choice" value="client" />
						<label for="client">
							<span class="radio__box">
								<span class="radio__box__inner">&nbsp;</span>
							</span>    
							<span class="radio__text">Я новый клиент</span>
						</label>
					</div>
				</li>					
			</ul>
		</fieldset>
		<fieldset class="center">
			<div class="type-submit">
				<?php echo CHtml::submitButton('Отправить'); ?>			
			</div> 
		</fieldset>
		<?php $this->endWidget(); ?>
	</div>	
</div>

<script type="text/javascript">
	/*&lt;![CDATA[*/
	jQuery("#test-02").mask("+7 (999) 999-99-99");
        
	jQuery('#request-form-02').yiiactiveform({'validateOnSubmit': true,
		'afterValidate':
				function(form, data, hasError) {
					if (!hasError) {
                                            var cur = $('#curer').find('input[type="radio"]:checked');                                            
                                            var status = cur.attr('id') == 'status' ? 'status' : 'new client';
                                            _gaq.push(["_trackEvent", "callback-request-footer", status, window.location.href]);                                             
						$.ajax({
							type: "POST",
							url: form[0].action,
							data: $(form).serialize(),
							success: function(ret) {
								$('.fancybox-close').trigger('click');
								var data = JSON.parse(ret);
								mobi03.showMessage(data.message.title, data.message.desc);
							}
						});
					}
				}
		, 'attributes': [{'id': 'test-02', 'inputID': 'test-02', 'errorID': 'RequestForm_userPhone_em_', 'model': 'RequestForm', 'name': 'userPhone', 'enableAjaxValidation': false, 'clientValidation': function(value, messages, attribute) {

					if (jQuery.trim(value) == '') {
						messages.push("\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u00abUser Phone\u00bb.");
					}

				}}], 'errorCss': 'error'});
	/*]]&gt;*/
</script>